package com.my.xinyidaixi.Fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.my.xinyidaixi.Adapter.gaoduanxihuGoodAdapter;
import com.my.xinyidaixi.Globe.MyApplication;
import com.my.xinyidaixi.Interface.Goods_interface;
import com.my.xinyidaixi.Model.GoodsItem;
import com.my.xinyidaixi.Overwrite.OverGridView;
import com.my.xinyidaixi.R;

import java.util.ArrayList;

/**
 * Created by zw on 2017/6/6.
 */
public class gaoduanxihufragment extends Fragment {

    private Context context= MyApplication.getInstance();
    private View view;
    private Goods_interface goods_interface;
    private OverGridView gaoduanxihugoodsitem;
    private ArrayList<GoodsItem> datalist;
    private gaoduanxihuGoodAdapter gaoduanxihuAdapter;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.gaoduanxihufragment_layout,container,false);
        initdata();
        return view;
    }

    @Override
    public void onAttach(Context context) {  //当fragment和activity被关联时调用。
        super.onAttach(context);
        goods_interface= (Goods_interface) context;
    }

    public  void  initdata()
    {
        gaoduanxihugoodsitem = (OverGridView) view.findViewById(R.id.GridView_gaoduanxihugoodsitem);

        datalist=GoodsItem.getGoodlist_gaoduanxihu();

        gaoduanxihuAdapter=new gaoduanxihuGoodAdapter(datalist,context);

        gaoduanxihuAdapter.huidiao_Goods_interface(goods_interface);

        gaoduanxihugoodsitem.setAdapter(gaoduanxihuAdapter);

        goods_interface.goods_gaoduanxihuadapter(gaoduanxihuAdapter);
    }
}
